<template>
	<view class="healthcare">
		<view class="back">
			<image class="back-img" @click="back" src="../../static/index/fanhui.png" mode=""></image>
			<text class="back-name">医疗健康</text>
		</view>
		<!-- banner -->
		<view class="banner">
			<view class="uni-padding-wrap">
				<view class="page-section swiper">
					<view class="page-section-spacing">
						<swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration">
							<swiper-item v-for="(item,index) in bannerList1" :key='index'>
								<view class="swiper-item uni-bg-red">
									<image class="img-banner" :src="item.image" mode=""></image>
								</view>
							</swiper-item>
						</swiper>
					</view>
				</view>
			</view>
		</view>
		<view class="healthy-choices">
			<view class="healthy-choices-title">
				<text>聚源变健康生活</text>
				<text>你的健康首选</text>
			</view>
			<view class="healthy-choices-box">
				<view class="healthy-box" @click="careBox(0)">
					<image src="../../static/healthy/xianshangwenzhen.png" mode=""></image>
					<text>线上问诊</text>
				</view>
				<view class="line"></view>
				<view class="healthy-box" @click="careBox(1)">
					<image src="../../static/healthy/baojianhe.png" mode=""></image>
					<text>保健盒</text>
				</view>
				<view class="line"></view>
				<view class="healthy-box" @click="careBox(2)">
					<image src="../../static/healthy/jiankangfuwu.png" mode=""></image>
					<text>健康服务</text>
				</view>
			</view>
		</view>
		<view class="capsule">
			<image src="../../static/healthy/jiaonang.png" mode=""></image>
		</view>
		<view class="product">
			<view class="product-title">
				<image src="../../static/healthy/yeleft.png" mode=""></image>
				<text>中药式养生产品</text>
				<image src="../../static/healthy/yeright.png" mode=""></image>
			</view>
			<!-- 卡片轮播 -->
			<view class="card-box">
				<swiper class="swiper-block" :indicator-dots="true" indicator-active-color="#FF7200" :autoplay="true" :interval="3000"
				 :duration="1000" circular='true' previous-margin='100rpx' next-margin='100rpx' current='0' @change="swiperChange">
					<swiper-item class="swiper-item" v-for="(item,index) in swiperImgUrls" :key='index'>
						<image :src="item.img" :class="['slide-image', currentIndex === index?'active':'']" mode="aspectFill"></image>
						<view class="swiper-item-box">
							<text style="font-size: 32rpx;font-weight: 500;color: #FF7200;text-align: center;">{{item.title}}</text>
							<text style="font-size: 32rpx;font-weight: bold;color: #333333;margin: 20rpx 0;">{{item.text}}</text>
							<view class="shop-box">
								<text>到手价</text>
								<text>{{item.integral}}积分</text>
								<view class="text">
									<image src="../../static/healthy/shopcar.png" mode=""></image>
								</view>
							</view>

						</view>
						<!-- 满减 -->
						<view class="full-minus" v-if="currentIndex === index" style="background-image: url('../../static/healthy/manjian.png');">
							满3000减300
						</view>
						<view class="full-minus2" v-else style="background-image: url('../../static/healthy/manjian2.png');">
							满3000减300
						</view>
					</swiper-item>
				</swiper>

			</view>
			<!-- 推荐 -->
			<view class="recommend">
				<view class="recommend-title">
					<text>为你推荐</text>
					<view class="recommend-line"></view>
					<text>健康好物优选</text>
				</view>
				<view class="recommend-box">
					<view class="recommend-shop" v-for="(item,index) in recommendList" :key="index">
						<image class="big-img" :src="item.img" mode=""></image>
						<text class="recommend-text">{{item.text}}</text>
						<view class="recommend-add">
							<text class="integral">{{item.integral}}积分</text>
							<image class="small-img" src="../../static/healthy/add.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-popup :show="show" v-model="show" mode="center" :round="true" borderRadius="10">
		            <view style="width: 670rpx;height: 296rpx;background: #FFFFFF;padding: 40rpx;">
		                <view class="tips">
		                	尊敬的用户您好，您正在进入的页面是
		                	线上问诊，一次问诊将会收取500积分。
		                </view>
						<view class="tips-bottom">
							<text @click="jump">确认前往</text>
							<text @click="show=false">返回首页</text>
						</view>
		            </view>
		</u-popup>
	</view>
</template>

<script>
	import {getBanner} from '@/service/banner.js'//banner
	export default {
		data() {
			return {
				show:false,//弹框
				bannerList1: [],
				swiperImgUrls: [{
						img: require('../../static/healthy/zhongyao.png'),
						title: '保梦安神片',
						text: '静心安睡  美梦安神',
						integral: '3000'
					},
					{
						img: require('../../static/healthy/zhongyao.png'),
						title: '保梦安神片',
						text: '静心安睡  美梦安神',
						integral: '3000'
					},
					{
						img: require('../../static/healthy/zhongyao.png'),
						title: '保梦安神片',
						text: '静心安睡  美梦安神',
						integral: '3000'
					}
				],
				currentIndex: 0,
				recommendList: [{
						img: require('../../static/healthy/anmoyi.png'),
						text: '秋冬季搭配良品贴身好物秋冬秋冬季搭配良品贴身好物',
						integral: '12000'
					},
					{
						img: require('../../static/healthy/anmoyi.png'),
						text: '秋冬季搭配良品贴身好物秋冬秋冬季搭配良品贴身好物',
						integral: '12000'
					},
					{
						img: require('../../static/healthy/anmoyi.png'),
						text: '秋冬季搭配良品贴身好物秋冬秋冬季搭配良品贴身好物',
						integral: '12000'
					},
					{
						img: require('../../static/healthy/anmoyi.png'),
						text: '秋冬季搭配良品贴身好物秋冬秋冬季搭配良品贴身好物',
						integral: '12000'
					},
				]
			}
		},
		onLoad() {
			this.getBanner();
		},
		methods: {
			//获取banner、
			getBanner(){
				let params = {
					type:5
				}
				getBanner(params).then(res=>{
					// console.log(res,'广告部分');
					this.bannerList1 = res.data
				})
			},
			back() {
				uni.navigateBack()
			},
			swiperChange(event) {
				// console.log(event)
				this.currentIndex = event.detail.current
			},
			//进入问诊页面
			jump(){
				uni.navigateTo({
					url:'/myPackageA/index/healthBox/online'
				})
			},
			//保健盒
			careBox(type){
				if(type==0){
					this.show = true
				}
				if(type==1){
					uni.navigateTo({
						url:'/myPackageA/index/healthBox/healthBox'
					})
				}
				if(type==2){
					uni.navigateTo({
						url:'/myPackageA/index/healthBox/medicare'
					})
				}
				
			}
		}
	}
</script>

<style lang="less" scoped>
	.tips{
		padding-bottom: 30rpx;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;
		line-height: 52rpx;
		border-bottom: 1px solid #F2F2F2;
	}
	.tips-bottom{
		height: 94rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		text:first-child{
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FF7200;
			flex: 1;
			border-right: 1px solid #F2F2F2;
		}
		text:last-child{
			height: 100%;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #999999;
			flex: 1;
		}
	}
	.recommend {
		margin-top: 60rpx;

		.recommend-box {
			width: 100%;
			height: auto;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.recommend-shop {
				width: 45%;
				height: 464rpx;
				background: #FFFFFF;
				box-shadow: 0px 4rpx 8rpx rgba(0, 0, 0, 0.16);
				opacity: 1;
				border-radius: 10rpx;
				margin-bottom: 34rpx;
				display: flex;
				flex-direction: column;
				padding: 10rpx;

				.big-img {
					width: 286rpx;
					height: 310rpx;
				}

				.recommend-text {
					font-size: 20rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					line-height: 18px;
					color: #333333;
					margin: 22rpx 0;
					padding: 0 10rpx;
				}

				.recommend-add {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 0 10rpx;
					.integral {
						font-size: 26rpx;
						font-family: Source Han Sans CN;
						font-weight: bold;
						color: #FF7200;
					}

					.small-img {
						width: 36rpx;
						height: 36rpx;
					}
				}
			}
		}

		.recommend-title {
			display: flex;
			border-bottom: 2px solid #E0DEDE;
			padding-bottom: 22rpx;
			align-items: center;
			margin-bottom: 28rpx;

			text:first-child {
				font-size: 18px;
				font-family: Source Han Sans CN;
				font-weight: 500;
				color: #333333;
			}

			.recommend-line {
				width: 2px;
				height: 14px;
				background: #DCDCDC;
				opacity: 1;
				margin: 0 12rpx;
			}

			text:last-child {
				font-size: 12px;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #999999;
			}
		}
	}

	.card-box .swiper-item-box {
		margin-top: 28rpx;
		display: flex;
		flex-direction: column;

		.shop-box {
			display: flex;
			align-items: center;

			text:first-child {
				width: 82rpx;
				height: 32rpx;
				line-height: 32rpx;
				text-align: center;
				background: #FF7200;
				border-radius: 8px;
				font-size: 20rpx;
				font-weight: 400;
				color: #FFFFFF;
			}

			text:nth-child(2) {
				font-size: 32rpx;
				font-weight: 400;
				color: #FF0000;
				margin: 0 12rpx;
			}

			.text {
				width: 38rpx;
				height: 38rpx;
				background: #FF0000;
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 28rpx;
					height: 22rpx;
				}
			}
		}
	}

	.full-minus {
		width: 150rpx;
		height: 42rpx;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		font-size: 20rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		text-align: center;
		color: #FFFFFF;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 99;
	}

	.full-minus2 {
		width: 86rpx;
		height: 24rpx;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		font-size: 10rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		text-align: center;
		color: #FFFFFF;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 99;
	}

	.card-box .swiper-block {
		height: 484rpx;
		width: 100%;
		position: relative;
	}

	.card-box .swiper-item {
		width: 314rpx !important;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: flex-start;
		overflow: unset;
		margin: 0 100rpx;
		padding: 20rpx;
		height: 382rpx !important;
		background-color: #FFFFFF;
		border-radius: 10px;
	}

	.card-box .slide-image {
		height: 186rpx;
		width: 286rpx;
		z-index: 1;
	}

	.card-box .active {
		transform: scale(1.14);
		transition: all 0.2s ease-in 0s;
		z-index: 20;
		background-color: #FFFFFF !important;
	}



	.healthcare {
		height: auto;
		padding-bottom: 20px;
	}

	.product {
		padding: 0 40rpx;

		.product-title {
			display: flex;
			align-items: center;
			justify-content: center;
			margin-bottom: 40rpx;

			image {
				width: 46rpx;
				height: 42rpx;
			}

			text {
				font-size: 36rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}
		}
	}

	.capsule {
		padding: 40rpx;
		width: 100%;

		image {
			width: 100%;
			height: 158rpx;
		}
	}

	.healthy-choices {
		padding: 0 40rpx;
		margin-bottom: 20rpx;

		.healthy-choices-box {
			width: 100%;
			height: 224rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			justify-content: center;

			.healthy-box {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				image {
					width: 120rpx;
					height: 120rpx;
				}

				text {
					font-size: 32rpx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
				}
			}

			.line {
				width: 4rpx;
				height: 162rpx;
				background: #F9F9F9;
				margin: 0 60rpx;
			}
		}

		.healthy-choices-title {
			display: flex;
			align-items: center;
			margin-bottom: 40rpx;

			text:first-child {
				font-size: 32rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}

			text:last-child {
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #999999;
				margin-left: 20rpx;
			}
		}
	}

	.back {
		padding-top: 80rpx;
		width: 100%;
		height: 176rpx;
		background-color: #1297F1;
		display: flex;
		align-self: center;
		padding-left: 0 !important;
		padding-right: 0 !important;

		.back-img {
			width: 40rpx;
			height: 40rpx;
			margin-top: 10rpx;
		}

		.back-name {
			font-size: 18px;
			line-height: 31px;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
			margin-right: 18rpx;
		}
	}

	.banner {
		margin-bottom: 40rpx;

		.swiper-item {
			height: 334rpx;

			.img-banner {
				width: 100%;
				height: 100%;
			}
		}
	}

	.uni-padding-wrap {
		width: 100%;
		padding: 0;
	}
</style>
